﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DoeObjects;
using DoeLibsMVC.Models;
using DoeLibsMVC.Security;

namespace DoeLibsMVC.Controllers
{
    public class TopicController : BaseController
    {
        public ActionResult Index()
        {
            return View();
		}

		public ActionResult Get(int id)
		{
			ViewBag.topicId = id;
			return View();
		}

		[HttpGet]
		[Authorize(Roles = UserCategoryHelper.STAFF_CATEGORY)]
		public ActionResult Edit(int id)
		{
			Topic topic = Topic.getByTopicId(id);
            ViewBag.topicId = id;

			if (topic == null)
			{
				base.Message = new HttpMessage("No topic for this topicId found", false);
				return RedirectToAction("Index", "Topic");
			}
			else
			{
				EditTopicModel etm = new EditTopicModel();
				etm.TopicName = topic.TopicName;
				return View(etm);
			}
		}
    }
}
